<template>
  <div class="medicineMessage">
    <!--    药品相关-->
    <form-message>
      <form-message-item v-if="isShow.zdyyp">
        <div slot="message">自定义药品：</div>
        <div slot="content">
          <el-input v-model="formInfo.zdyyp" placeholder="请输入自定义药品" />
        </div>
        <div slot="buttons">
          <el-button
            size="mini"
            type="primary"
            @click="chooseDialog('自定义药品',father,'zdyyp',true)"
          >选择</el-button>
          <el-button size="mini" type="primary">清除</el-button>
        </div>
      </form-message-item>

      <form-message-item v-if="isShow.yp">
        <div slot="message">药品：</div>
        <div slot="content">
          <el-input v-model="formInfo.yp" placeholder="请输入药品" />
        </div>
        <div slot="buttons">
          <el-button size="mini" type="primary">选择</el-button>
          <el-button size="mini" type="primary">清除</el-button>
        </div>
      </form-message-item>

      <form-message-item v-if="isShow.mjyp" :is-long="true">
        <div slot="message">麻精药品：</div>
        <div slot="content">
          <el-checkbox-group v-model="formInfo.mjyp">
            <el-checkbox label="麻醉药品"><span class="fontSize12">麻醉药品</span></el-checkbox>
            <el-checkbox label="精一药品"><span class="fontSize12">精一药品</span></el-checkbox>
            <el-checkbox label="精二药品"><span class="fontSize12">精二药品</span></el-checkbox>
          </el-checkbox-group>
        </div>
      </form-message-item>
      <form-message-item v-if="isShow.jbyw">
        <div slot="message">基本药物：</div>
        <div slot="content">
          <el-checkbox v-model="formInfo.jbyw" label="使用" ><span class="fontSize12">使用</span></el-checkbox>
        </div>
      </form-message-item>

      <form-message-item v-if="isShow.yplx" :is-long="true">
        <div slot="message">药品类型：</div>
        <div slot="content">
          <el-checkbox-group v-model="formInfo.yplx">
            <el-checkbox label="中成药"><span class="fontSize12">中成药</span></el-checkbox>
            <el-checkbox label="中药饮品"><span class="fontSize12">中药饮品</span></el-checkbox>
            <el-checkbox label="化学药品"><span class="fontSize12">化学药品</span></el-checkbox>
            <el-checkbox label="生物制剂"><span class="fontSize12">生物制剂</span></el-checkbox>
          </el-checkbox-group>
        </div>
      </form-message-item>

      <form-message-item v-if="isShow.kjylx" :is-long="true">
        <div slot="message">抗菌药类型：</div>
        <div slot="content">
          <el-checkbox-group v-model="formInfo.kjylx">
            <el-checkbox label="抗细菌药"><span class="fontSize12">抗细菌药</span></el-checkbox>
            <el-checkbox label="抗真菌药"><span class="fontSize12">抗真菌药</span></el-checkbox>
            <el-checkbox label="抗结核/麻风药"><span class="fontSize12">抗结核/麻风药</span></el-checkbox>
            <el-checkbox label="其他抗菌药"><span class="fontSize12">其他抗菌药</span></el-checkbox>
          </el-checkbox-group>
        </div>
      </form-message-item>

      <form-message-item v-if="isShow.kjyjb" :is-long="true">
        <div slot="message">抗菌药级别：</div>
        <div slot="content">
          <el-checkbox-group v-model="formInfo.kjyjb">
            <el-checkbox label="特殊使用"><span class="fontSize12">特殊使用</span></el-checkbox>
            <el-checkbox label="限制使用"><span class="fontSize12">限制使用</span></el-checkbox>
            <el-checkbox label="非限制使用"><span class="fontSize12">非限制使用</span></el-checkbox>
          </el-checkbox-group>
        </div>
      </form-message-item>

      <form-message-item v-if="isShow.gytj">
        <div slot="message">给药途径：</div>
        <div slot="content">
          <el-input v-model="formInfo.gytj" placeholder="请输入给药途径" />
        </div>
        <div slot="buttons">
          <el-button size="mini" type="primary">选择</el-button>
          <el-button size="mini" type="primary">清除</el-button>
        </div>
      </form-message-item>

      <form-message-item v-if="isShow.ypfy">
        <div slot="message">药品费用：</div>
        <div slot="content">
          <el-row>
            <el-col :span="11"><el-input v-model="formInfo.ypfy.start" /></el-col>
            <el-col :span="2"><span style="padding-left: 5px">至</span></el-col>
            <el-col :span="11"><el-input v-model="formInfo.ypfy.end" /></el-col>
          </el-row>
        </div>
      </form-message-item>


      <form-message-item v-if="isShow.jblx" :is-long="true">
        <div slot="message">疾病类型：</div>
        <div slot="content">
          <el-checkbox-group v-model="formInfo.jblx">
            <el-checkbox label="感染性疾病"><span class="fontSize12">感染性疾病</span></el-checkbox>

          </el-checkbox-group>
        </div>
      </form-message-item>

      <form-message-item v-if="isShow.kjsby">
        <div slot="message">抗精神病药：</div>
        <div slot="content">
          <el-radio v-model="formInfo.kjsby" label="1"><span class="fontSize12">是</span></el-radio>
          <el-radio v-model="formInfo.kjsby" label="0"><span class="fontSize12">否</span></el-radio>
        </div>
      </form-message-item>
      <form-message-item v-if="isShow.kyyyp">
        <div slot="message">抗抑郁药：</div>
        <div slot="content">
          <el-radio v-model="formInfo.kyyyp" label="1"><span class="fontSize12">是</span></el-radio>
          <el-radio v-model="formInfo.kyyyp" label="0"><span class="fontSize12">否</span></el-radio>
        </div>
      </form-message-item>
    </form-message>
  </div>
</template>

<script>
import FormMessage from './FormMessage'
import FormMessageItem from './FormMessageItem'
export default {
  name: 'MedicineMessage',
  components: {
    FormMessage,
    FormMessageItem
  },
  props: {
    isShow: {
      zdyyp: false, yp: false, mjyp: false,
      jbyw: false, yplx: false, kjylx: false, kjyjb: false,
      gytj: false, ypfy: false, kjsby: false, kyyyp: false
    },
    father: {
      type: String,
      default: null
    },
    isPassValue: {
      type: Boolean,
      default: false
    },
    selectedResult: {
      type: String,
      default: null
    }
  },
  data() {
    return {
      formInfo: {
        zdyyp: '', yp: '', mjyp: [],
        jbyw: [], yplx: [], kjylx: [], kjyjb: [],
        gytj: '', ypfy: {
          start: '',
          end: ''
        }, kjsby: '', kyyyp: ''
      },
      // 对话框数据
      dialogInfo: {
        title: '',
        father: '',
        infoData: '',
        isTransfer: null
      }
    }
  },
  watch: {
    isPassValue() {
      if (this.isPassValue === true) {
        this.$emit('acquireInfo', 'baseMessageInfo', this.formInfo)
      }
    },
    selectedResult() {
      if (this.selectedResult === '') {
        console.log(this.selectedResult)
      } else {
        this.formInfo[this.dialogInfo.infoData] = this.selectedResult
        // console.log(this.formInfo)
      }
    }
  },
  methods: {
    chooseDialog(title, father, infoData, isTransfer) {
      this.dialogInfo.title = title
      this.dialogInfo.father = father
      this.dialogInfo.infoData = infoData
      this.dialogInfo.isTransfer = isTransfer
      this.$emit('chooseDialog', this.dialogInfo)
    },
    cleanInput(value) {
      for (const item in this.formInfo) {
        if (item === value) {
          this.$set(this.formInfo, value, '')
          break
        }
      }
    }
  }
}
</script>

<style scoped lang="scss">
.medicineMessage{
  font-size: 12px;
}
.fontSize12{
  font-size: 12px !important;
}
.el-button, .el-input{
  font-size: 12px;
}
</style>
